package jok.set;

public class Student implements Comparable<Student> {

	private Integer id;

	private String name;

	private Integer age;

	public Student(Integer id, String name, Integer age) {
		super();
		this.id = id;
		this.name = name;
		this.age = age;
	}

	public Integer getId() {
		return id;
	}

	public void setId(Integer id) {
		this.id = id;
	}

	public String getName() {
		return name;
	}

	public void setName(String name) {
		this.name = name;
	}

	public Integer getAge() {
		return age;
	}

	public void setAge(Integer age) {
		this.age = age;
	}

	@Override
	public String toString() {
		return "Student [id=" + id + ", name=" + name + ", age=" + age + "]";
	}

	@Override
	public boolean equals(Object obj) {
		if (obj instanceof Student) {
			return compareTo((Student) obj) == 0;
		}
		return false;
	}

	@Override
	public int hashCode() {
		return 1;
	}

	@Override
	public int compareTo(Student o) {
		int result = this.id - o.id;
		if (result == 0) {
			result = this.age - o.age;
			if (result == 0) {
				result = this.name.compareTo(o.name);
			}
		}
		return result;
	}
}
